Fix "none" item spawning from reloading a loaded smoking rack #38477
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
SUMMARY: Bugfixes "Fix 'none' item spawning from reloading a loaded smoking rack"
Purpose of change
Fixes #38462. Loading charcoal into a smoking rack with charcoal and smokeable items already in it, and then answering "Y" to unload the charcoal, was leading to a bug where you got an item called "none" in your inventory.
Describe the solution
The error was happening because the call to only_item() was assuming there would only be one item in the smoker's item stack.
So I changed it to look through the stack until it finds the smoker's ammo, and then picking that up.
Describe alternatives you've considered
Doing nothing. This is an easy one to work around by not doing the Unload as part of that dialogue.
Testing
Spawned smoking racks before and after, loaded with fruit and charcoal, and reloading them. Afterwards there was no error and the item quantities stayed in balance.
Additional context
Still being new to the codebase, if there's a cleaner way of just saying "pick up the ammo item out of this stack", let me know!
As an aside, smoking rack load/unload behaviour in general is a little inconsistent with how, say, charcoal smokers work, which is annoying, but tackling that is a much bigger task.